package com.dlsy.ygj.util;

import java.io.Serializable;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.springframework.orm.hibernate3.HibernateCallback;

import net.taobaoge.common.framework.dao.impl.BaseDAOImpl;

public class EmptyData extends BaseDAOImpl<Serializable> {

	public void deleteStorefront(final int storefront_id, final String table)
			throws SQLException {
		getHibernateTemplate().execute(new HibernateCallback() {
			
			public Object doInHibernate(Session session)
					throws HibernateException, SQLException {
				System.out.println("------------"+table);
				Transaction tx = null;
				Connection conn = null;
				Statement stat = null;
				String sql = "delete from " + table + " where storefront_id="
						+ storefront_id;
				System.out.println(sql);
				tx = session.beginTransaction();
				conn = session.connection();
				stat = conn.createStatement();
				stat.execute(sql);
				System.out.println("------");
				tx.commit();
				stat.close();
				conn.close();
				return null;
			}
		});
	}
}
